package com.hnguigu.health.houduan.lcj.controller_lcj;

import com.hnguigu.health.houduan.lcj.pojo_lcj.*;
import com.hnguigu.health.houduan.lcj.pojo_lcj.fenzu;
import com.hnguigu.health.houduan.lcj.pojo_lcj.THealthmgr_lcj;
import com.hnguigu.health.houduan.lcj.service_lcj.TFollowupjournalService_lcj;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

@Controller
@RequestMapping("/tfollow")
public class TFollowupjournalController_lcj {

    @Autowired(required = false)
    TFollowupjournalService_lcj tFollowupjournalService_lcj;

    @GetMapping("/gethealth")
    @ResponseBody
    public List<THealthmgr_lcj> gethealth(){
       return tFollowupjournalService_lcj.t_healthmgrAllList();
    }

    @GetMapping("/gettjfx")
    @ResponseBody
    public List<fenzu> gettjfx(String name){
        System.out.println(name+"健康管理师");
        if(name==""){
            return tFollowupjournalService_lcj.tjfx(name);
        }else{
            THealthmgr_lcj byId = tFollowupjournalService_lcj.getById(name);
            return tFollowupjournalService_lcj.tjfx(byId.getHealthMgrId().toString());
        }
    }

    @PostMapping("/ganyu")
    @ResponseBody
    public List<Health_count_lcj> ganyu(){
        List<fenzu1> gyhf = tFollowupjournalService_lcj.gyhf();
        List<fenzu1> gyjs = tFollowupjournalService_lcj.gyjs();
        List<fenzu1> gyfa = tFollowupjournalService_lcj.gyfa();
        List<Health_count_lcj> list=new ArrayList<>();
        for (int i=0;i<gyfa.size();i++){
            Health_count_lcj health_count_lcj = new Health_count_lcj();
            String cc = gyfa.get(i).getCc();
            String dd = gyfa.get(i).getDd();
            health_count_lcj.setName(cc);
            health_count_lcj.setGyfa(dd);
            String dd2 = gyhf.get(i).getDd();
            health_count_lcj.setGyhf(dd2);
            String dd1 = gyjs.get(i).getDd();
            health_count_lcj.setGyjs(dd1);
            list.add(health_count_lcj);
        }
        return list;
    }
}
